package com.hudongwx.shansun.activity;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.Toast;

import com.hudongwx.shansun.R;

import org.xutils.view.annotation.ContentView;
import org.xutils.view.annotation.Event;
import org.xutils.view.annotation.ViewInject;
import org.xutils.x;

@ContentView(R.layout.activity_home_select)
public class HomeSelectActivity extends AppCompatActivity {
    @ViewInject(R.id.select_ll_1)
    private LinearLayout linearLayout;
    @ViewInject(R.id.selector_iv_1)
    private ImageView iv1;
    @ViewInject(R.id.selector_iv_2)
    private ImageView iv2;
    @ViewInject(R.id.selector_iv_3)
    private ImageView iv3;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        x.view().inject(this);

    }

    @Event(R.id.selector_btn)
    private void select_Btn(View view) {
        if (iv1.isSelected()) {
            Toast.makeText(this, "男", Toast.LENGTH_SHORT).show();
        } else if (iv2.isSelected()) {
            Toast.makeText(this, "女", Toast.LENGTH_SHORT).show();
        } else {
            Toast.makeText(this, "不限", Toast.LENGTH_SHORT).show();
        }
        finish();
    }

    @Event(value = {R.id.selector_iv_1})
    private void imgBtn(View view) {
        if (iv1.isSelected()) {
            iv1.setSelected(false);

        } else {
            iv1.setSelected(true);
            iv2.setSelected(false);
            iv3.setSelected(false);
        }
    }

    @Event(value = {R.id.selector_iv_2})
    private void img2Btn(View view) {
        if (iv2.isSelected()) {
            iv2.setSelected(false);

        } else {
            iv2.setSelected(true);
            iv1.setSelected(false);
            iv3.setSelected(false);
        }
    }

    @Event(value = {R.id.selector_iv_3})
    private void img3Btn(View view) {
        if (iv3.isSelected()) {
            iv3.setSelected(false);

        } else {
            iv3.setSelected(true);
            iv2.setSelected(false);
            iv1.setSelected(false);
        }
    }

    @Event(value = {R.id.selector_iv_4, R.id.selector_iv_5, R.id.selector_iv_6, R.id.selector_iv_7, R.id.selector_iv_8, R.id.selector_iv_9, R.id.selector_iv_10, R.id.selector_iv_11})
    private void imBtn(View view) {
        if (view.isSelected()) {
            view.setSelected(false);

        } else {
            view.setSelected(true);
        }

    }
}
